{% extends "master.html" %}
{% block subtitle %} - 主面板 - 调拨管理 - 查找商品{% endblock %}

{% block extJS %}
<script language="JavaScript" type="text/javascript">
//<![CDATA[    
    function toCreateDN(){
        var msg = [];
        clearMsg();
        $(".err").removeClass("err");
        
        if( $("input[name='item']:checked").length < 1 ){
            msg.push('请选择至少一个商品！');
        }
        if(msg.length>0){
            alertError(msg);
            return false;
        }else{
            $('.resultForm').submit()
        }
    }
//]]>
</script>
{% endblock %}


{% block main %}
<div class="container">
    <div class="row">
        <ol class="breadcrumb">
          <li><a href="{{url_for('bpRoot.view')}}">主面板</a></li>
          <li><a href="{{url_for('bpTns.view')}}">调拨管理</a></li>
          <li class="active">查找商品</li>
        </ol>
    </div>
    <div class="row">
        {{mymacros.render_search_form(form,3)}}
    </div>           
    <div class="row">
        <div class="btn-toolbar pull-right">
            <div class="btn-group"><button type="button" class="btn btn-default" onclick="$('.searchForm').submit()">{{BTN_SEARCH}}</button></div>
            <div class="btn-group"><button type="button" class="btn btn-primary" onclick="toCreateDN()">申请调拨</button></div>
        </div>
    </div>     
    <div class="row">
        <form method="POST" action="{{url_for('.view',action='applySend')}}" class="resultForm">
        <table class="table table-bordered">
            <thead>
            <tr>
                <td class="col-md-1">&nbsp;<input type="checkbox" onclick="selectall(this,'item')"/></td>
                <td class="col-md-3">商品编号</td>
                <td class="col-md-2">商品名称</td>
                <td>商品描述</td>
                <td class="col-md-2">所在仓位</td>
                <td class="col-md-2">现存/可用数量</td>
            </tr>
            </thead>
            <tbody>
                {% for (pdt,ivt,ip) in result %}
                    <tr>
                        <td>&nbsp;
                            {% if ivt.referID|string != getShopID() %}                            
                                {% if ivt.name not in ['IN_TRAVEL','SOLD_OUT','WASTAGE','PROCESS','PURCHASE'] and ip.availableQty > 0 %}
                                <input type="checkbox" name="item" value="item_{{pdt.id}}_{{ivt.id}}" class="cb"/>
                                {% endif %}
                            {% endif %}
                        </td>
                        <td>{{mymacros.render_goto_popup_pdt(pdt, loop.first)}}</td>
                        <td>{{pdt.name}}</td>
                        <td>{{pdt.makeDesc()|f}}</td>
                        <td>{{ivt|f}}</td>
                        {% if ivt.name in ['IN_TRAVEL','SOLD_OUT','WASTAGE','PROCESS','PURCHASE'] %}
                            <td>{{ip.qty}}/-</td>
                        {% else %}
                            <td>{{ip.qty}}/{{ip.availableQty}}</td>
                        {% endif %}
                    </tr>
                {% endfor %}
        </table>
        <p><sub>*</sub>可用数量 = 现存数量 - 被预留或将要出库的数量</p>
        </form>
    </div>

</div>
{% endblock %}